﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NetC
{
    public partial class InfoDetail : Form
    {
        //srun info flag
        public int srun_flag = 0;
        public InfoDetail()
        {
            InitializeComponent();
        }

        private void InfoDetail_Load(object sender, EventArgs e)
        {
            int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 277;
            int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height - 2;
            this.Opacity = 0.0;
            timer_ctrlshow.Enabled = true;
            this.SetDesktopLocation(x, y);
            this.ShowInTaskbar = false;
        }

        public void set_Opacity()
        {
            this.Opacity += 0.1; 
            if (this.Opacity == 1)
            {
                timer_ctrlshow.Enabled = false;
                //timer_stay.Enabled = true;
            }
        }

        public void set_Opacity2()
        {
            this.Opacity -= 0.2;
            if (this.Opacity <= 0)
            {
                this.Dispose();
            }
        }

        private void timer_ctrlshow_Tick(object sender, EventArgs e)
        {
            set_Opacity();
        }

        private void timer_stay_Tick(object sender, EventArgs e)
        {
            timer_ctrlquit.Enabled = true;
            timer_stay.Enabled = false;
        }

        private void timer_ctrlquit_Tick(object sender, EventArgs e)
        {
            set_Opacity2();
        }

        private void InfoDetail_FormClosing(object sender, FormClosingEventArgs e)
        {
            timer_ctrlquit.Enabled = true;
            e.Cancel = true;
        }

        private void webBrowser_main_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (srun_flag == 1)
            {
                this.Width = 420;
                this.Height = 277;
                int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width - 12;
                int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height - 2;
                this.SetDesktopLocation(x, y);
                this.FormBorderStyle = FormBorderStyle.Sizable;
                this.MaximizeBox = true;
                //not display the login window
                webBrowser_main.Document.InvokeScript("do_close");

            }
        }
 
    }
}
